<template>
	<view class="page-set-up">
		<u-navbar title="修改" back-icon-color="#000" :border-bottom="false"
		title-size="36" title-color="#000" title-bold></u-navbar>
		<view class="list-warp u-margin-top-20">
			<view class="list-item u-flex u-row-between u-col-center">
				<view class="list-left">设置昵称</view>
				<view class="list-right u-flex u-col-center u-flex-1 u-margin-left-30">
					<input type="text" class="u-flex-1" v-model="nickname" value="" />
				</view>
			</view>
		</view>
		
		<view class="list-warp u-margin-top-20">
			<view class="list-item u-flex u-row-between u-col-center">
				<view class="list-left">上传头像</view>
				<view class="list-right u-flex u-row-between u-col-center">
					<image :src="logo.slice(0,4) == 'http'?logo:$baseUrl + logo" mode="aspectFill" @click="uploadAvatar"></image>
				</view>
			</view>
		</view>
		<u-button type="error" shape="circle" class="custom-style" @click="submit">保存</u-button>
		<u-toast ref="uToast" />
	</view>
</template>

<script>
	import { commonGet } from "@/api/commonapi.js"
	import uploadAvatar from "@/common/uploadAvatar.js"
	export default {
		mixins:[uploadAvatar],
		data() {
			return {
				$baseUrl:"",
				nickname:"",
				_creatememid:"",
				userInfo:null
			}
		},
		onLoad() {
			this.$baseUrl = this.baseUrl
			if(this.$store.state.userIn){
				this.nickname = JSON.parse(this.$store.state.userIn).nickname
				this._creatememid = JSON.parse(this.$store.state.userIn).id
				this.userInfo = JSON.parse(this.$store.state.userIn)
			}
		},
		methods: {
			goNextPage(type,url,params){
				this.$u.route({
					type:type,
					url: url,
					params:params
				})
			},
			submit(){
				let _this = this
				let query = {
					ak:_this.$store.state.token,
					cmd:"mMember_update_proc_info",
					para:JSON.stringify({
						"pageid":"3341",
						"id":_this._creatememid,
						"logo":_this.logo,
						"nickname":_this.nickname,
						"signnature":""
					})
				}
				commonGet(query,({Message})=>{
					if(Message == "操作成功！"){
						_this.userInfo.logo = _this.logo
						_this.userInfo.nickname = _this.nickname
						_this.$store.commit('userIn', JSON.stringify(_this.userInfo));
						this.$refs.uToast.show({title: '修改成功',type: 'success',back:true})
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
.page-set-up{
	background-color: #f5f5f5;
	overflow: hidden;
	height: 100vh;
	.header{
		background-color: #fff;
		.header-left{
			image{
				width: 124rpx;
				height: 124rpx;
				border-radius: 100%;
			}
			.nickname{
				font-weight: bold;
			}
		}
	}
	.list-warp{
		padding: 0 30rpx;
		background-color: #fff;
		.list-item{
			height: 108rpx;
			.list-left{
				font-size: 34rpx;
			}
			.list-right{
				color: #666666;
				font-size: 30rpx;
				image{
					width: 80rpx;
					height: 80rpx;
					border-radius: 100%;
				}
			}
		}
	}
	.line{
		width: 100%;
		height: 1px;
		background-color: #e5e5e5;
	}
	.custom-style {
		background-color: #c40200;
		margin: 73rpx 30rpx;
		font-size: 30rpx;
		
	}
}
</style>
